import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalNewcontentPage(Base):
    """
     我的消息详情页
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.content_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.content_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 标题图标
        self.content_lift_title_icon = (By.XPATH, Personal.RESOURCE_ID.format("iv_message_detail_icon"))

        # 标题文案
        self.content_right_title_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_message_detail_title"))

        # 消息时间
        self.content_new_time_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_message_detail_date"))

        # 具体消息内容
        self.content_specific_content_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_message_detail_content"))

        # 满意度标题
        self.content_satisfaction_title_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_product_satisfaction"))

        # 满意按钮
        self.content_satisfaction_yes_btn = (By.XPATH, Personal.RESOURCE_ID.format("satisfaction_linear"))

        # 不满意按钮
        self.content_satisfaction_no_btn = (By.XPATH, Personal.RESOURCE_ID.format("non_satisfaction_linear"))

        # 不满意建议
        self.content_suggest_input = (By.XPATH, Personal.RESOURCE_ID.format("et_write_advice"))

        # 提交按钮
        self.content_submit_btn = (By.XPATH, Personal.RESOURCE_ID.format("bt_post_message"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.content_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.content_back_btn)

    def get_lift_title(self):
        """
        获取详情页标题图标

        :return:获取元素
        """
        return self.find_element_o(self.content_lift_title_icon)

    def get_right_title(self):
        """
        获取详情页标题

        :return:获取元素
        """
        return self.find_element_o(self.content_right_title_text)

    def get_new_time(self):
        """
        获取详情页时间

        :return:获取元素
        """
        return self.find_element_o(self.content_new_time_text)

    def get_specific_content(self):
        """
        获取详情页具体问题

        :return:获取元素
        """
        return self.find_element_o(self.content_specific_content_text)

    def get_satisfaction_title(self):
        """
        获取详情页满意度标题

        :return:获取元素
        """
        return self.find_element_o(self.content_satisfaction_title_text)

    def click_satisfaction_yes(self):
        """
        点击满意按钮

        :return:None
        """
        self.click_element(self.content_satisfaction_yes_btn)

    def click_satisfaction_no(self):
        """
        点击不满意按钮

        :return:None
        """
        self.click_element(self.content_satisfaction_no_btn)

    def input_suggest(self, index="这是一条建议"):
        """
        建议输入框
        输入框
        :return:输入元素
        """
        self.input_text(self.content_suggest_input, index)

    def get_suggest_text(self):
        """
        获取建议文本
        输入框
        :return:输入元素
        """
        return self.find_element_o(self.content_suggest_input)

    def click_submit(self):
        """
        点击提交按钮

        :return:None
        """
        self.click_element(self.content_submit_btn)

    def get_submit(self):
        """
        获取提交按钮属性

        :return:None
        """
        return self.find_element_o(self.content_submit_btn)

    def is_display_personal_new_content(self):
        """
        是否存在反馈详情界面

        :return: bool
        """
        return self.is_display(self.content_right_title_text)

    def is_toast_personal_content(self):
        """
        判断提交是否成功

        :return: bool
        """
        return self.is_toast_exist(text="提交成功")
